package dobest.ray.com.jiongjiong.logicCache.cacheBaseLogic;

import android.content.Context;

import com.dobest.ray.corelibs.logic.BaseLogic;

import dobest.ray.com.jiongjiong.bean.BaseData;
import dobest.ray.com.jiongjiong.constants.Urls;
import dobest.ray.com.jiongjiong.logicCache.BaseManagerCache;


public class LoginManager extends BaseManagerCache {

    /**
     * 登陆
     *
     * @param c
     * @param phone
     * @param password
     * @param l
     */
    public void doLogin(Context c, String phone, String password,
                        BaseLogic.NListener<BaseData> l) {

        logic.edit(c).addParam("phone", phone).addParam("password", password)
                .setUrl(Urls.LOGIN_URL).setListener(l)
                .setBaseClass(BaseData.class);
        logic.doPost();
    }


    /**
     * 注册
     *
     * @param c
     * @param phone
     * @param password
     * @param code
     * @param l
     */
    public void doRegister(Context c, String phone, String password, String code,
                           BaseLogic.NListener<BaseData> l) {
        logic.edit(c).addParam("phone", phone).addParam("password", password).addParam("code", code)
                .setUrl(Urls.REGISTER_URL).setListener(l)
                .setBaseClass(BaseData.class);
        logic.doPost();
    }

    /**
     * 获取authkey
     *
     * @param c
     * @param uid
     * @param l
     */
    public void getAuthKey(Context c, String uid,
                           BaseLogic.NListener<BaseData> l) {
        logic.edit(c).addParam("uid", uid)
                .setUrl(Urls.GET_AUTH_KEY).setListener(l)
                .setBaseClass(BaseData.class);
        logic.doPost();
    }

    /**
     *
     * @param c
     * @param uid
     * @param l
     */
    public void getVCode(Context c, String uid,
                           BaseLogic.NListener<BaseData> l) {
        logic.edit(c).addParam("uid", uid)
                .setUrl(Urls.GET_V_CODE).setListener(l)
                .setBaseClass(BaseData.class);
        logic.doPost();
    }
}
